package com.dempsey.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dempsey.user.dao.Address;
import com.dempsey.user.dao.User;
import com.dempsey.user.mapper.UserMapper;
import com.dempsey.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Dempsey
 * @description 针对表【user】的数据库操作Service实现
 * @createDate 2022-05-01 02:15:53
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User createUser(User user) {
        userMapper.insert(user);
        return getUserById(user.getUserId());
    }

    @Override
    public User updateUser(User user) {
        userMapper.updateById(user);
        return getUserById(user.getUserId());
    }

    @Override
    public User getUserById(int userId) {
        return userMapper.selectById(userId);
    }

    @Override
    public User getUserByUsername(String username) {
        QueryWrapper<User> qw = new QueryWrapper<>();
        qw.eq("username", username);
        return userMapper.selectOne(qw);
    }

    @Override
    public List<Address> getAddressesByUserId() {
        return null;
    }

    @Override
    public List<Address> getAddressesById() {
        return null;
    }

    @Override
    public void createAddress() {

    }

    @Override
    public void disableAddress() {

    }
}




